package pe.sonrisas.tools.view;

import Complementos.Conexion_BD;
import Complementos.Validar;
import Complementos.Visual;
import Control.*;
import Modelo.Tratamiento;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;


/*
 * frmReservaCita.java
 *
 * Created on 14/08/2011, 03:38:42 PM Programador : Diego Alvarado . Descripcion
 * : Formulario para reserva de citas . Última modificación : 18/08/2011
 * Observaciones : Falta ver cómo vamos a dejar el asunto del horario de 1 a 23
 * hs. o 1 a 12 con AM y PM. Falta validar los campos de datos del paciente
 * (cod,nombre,tel,cel,proposito,monto). Al registrar una reserva en una fecha
 * reservada el mensaje está OK.
 *
 *
 * Modificacion Bruno 20/8 17hs - se aumentarno las filas de 4 a 19 de la tabla
 * 'paciente hora' - se movio a Validar el metodo 'formatearFechaDeCalendario '
 * - ahora la tablita de 'paciente hora' ya no es editable y se cambio su orden
 * , 'hora paciente'. - dps de hacer un registro de cita la tabla de horarios
 * sea actualiza - cambie el formato de la tabla de horarios(ahora esta al
 * costado) - hora la tabla solo muestra los horarios hh-mm y el nombre de
 * paciente
 *
 * Modificaciones Bruno 21/08 21.05 - se agrego icono al programa y se parcho la
 * ruta de las imagenes 24.00 - se valida q el codigo no este vacio 22/8 24.00 -
 * se agrego el aspecto mac 23/8 1.00 - se valida esVacio en txtNombreKeyPressed
 * se valida nombre y tel obligatorio , se muestra las citas del día
 *
 * Modificaciones Diego 23/8 15.00 - Se cambia el query del
 * mostrarReservasDelDia(), para filtrar y que solo se muestren las reservas
 * activas. - Se cambia el estado 'Activo' por 'Activa' en todos los querys de
 * registro. - Se actualiza en la BD el nuevo estado 'Activa'.
 *
 * Modificaciones Diego 25/08 04.40 - Se modifica el txtProposito por
 * comboMotivoConsulta, este carga los tratamientos mediante cargarTratamientos
 * que trae la data de la tabla Tratamiento. - Se agrega a la tabla
 * tblReservasDelDia la columna tratamiento que mostrará el tipo de
 * tratamiento/motivo de consulta que se realiza el paciente. - Se agrega el
 * método mostrarReserva(String cod) que es llamado desde frmReporteReservas, y
 * sirve para mostrar los datos seleccionados en el Reporte en este formulario.
 *
 ** Observaciones: - El código del evento del btnRegistrarActionPerformed se
 * puede optimizar bastante, queda pendiente revisarlo y refactorizarlo - Queda
 * por revisar el asunto de los calendarios
 */


public class frmReservaCita extends javax.swing.JDialog {
   
    Conexion_BD co = new Conexion_BD();
    ResultSet rs = null;
    Validar validar = new Validar();
    Tratamiento t = new Tratamiento();
    String codreserva;
    Vector<Vector> odontologos = new Vector<Vector>();
    ArrayList<ArrayList> motivos = new ArrayList<ArrayList>();
    

    public frmReservaCita(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        this.setIconImage(new ImageIcon(getClass().getResource("/pe/sonrisas/tools/imagenes/comun/logo1.png")).getImage());
//        setearFecha();
        cargarTratamientos();
        cargarOdontologos();
        cargarMotivos();

        Calendar c = dateCalendar.getSelectedDate();
        dateCalendar.setSelectedDate(c);

        /*
         * Cómo setear la fecha que se me re cante las pelotas en el calendar
         */
        //Calendar cambiarFecha = Calendar.getInstance();
        //cambiarFecha.set(2011, 7, 31);
        //dateCalendar.setSelectedDate(cambiarFecha);


        rbtNo.setSelected(true);
        rbtNoActionPerformed(null);

    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        rbtGroupPaciente = new javax.swing.ButtonGroup();
        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jPanel3 = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        txtCel = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        txtNombre = new javax.swing.JTextField();
        txtCodPaciente = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        chkBoxAdelanto = new javax.swing.JCheckBox();
        txtAdelanto = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        rbtSi = new javax.swing.JRadioButton();
        rbtNo = new javax.swing.JRadioButton();
        jLabel1 = new javax.swing.JLabel();
        comboDr = new javax.swing.JComboBox();
        txtTel = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        comboMotivo = new javax.swing.JComboBox();
        txtPaterno = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        txtMaterno = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        jLabel7 = new javax.swing.JLabel();
        comboHora = new javax.swing.JComboBox();
        jLabel8 = new javax.swing.JLabel();
        comboMins = new javax.swing.JComboBox();
        jLabel9 = new javax.swing.JLabel();
        dateCalendar = new datechooser.beans.DateChooserCombo();
        btnRegistrarReserva = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        tblReservasDelDia = new javax.swing.JTable();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("..::  Sonrisas Tools :..    Reserva de cita");
        setBackground(java.awt.Color.black);
        setResizable(false);

        jPanel2.setBackground(new java.awt.Color(204, 204, 255));
        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 153)), "Reserva de cita", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tunga", 0, 24), new java.awt.Color(255, 255, 153))); // NOI18N

        jPanel3.setBackground(new java.awt.Color(204, 204, 255));
        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 153)), "Ingrese datos", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tunga", 1, 14), new java.awt.Color(255, 255, 153))); // NOI18N

        jLabel5.setText("Motivo de consulta:");

        jLabel6.setText("Celular:");

        txtCel.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtCelKeyPressed(evt);
            }
        });

        jLabel4.setText("Nombre:");

        txtNombre.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtNombreKeyPressed(evt);
            }
        });

        txtCodPaciente.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtCodPacienteKeyPressed(evt);
            }
        });

        jLabel3.setText("Código paciente:");

        chkBoxAdelanto.setBackground(new java.awt.Color(204, 204, 255));
        chkBoxAdelanto.setText("Adelanto");
        chkBoxAdelanto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chkBoxAdelantoActionPerformed(evt);
            }
        });

        txtAdelanto.setEditable(false);
        txtAdelanto.setText("0.00");
        txtAdelanto.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtAdelantoKeyPressed(evt);
            }
        });

        jLabel2.setText("Paciente nuevo:");

        rbtSi.setBackground(new java.awt.Color(204, 204, 255));
        rbtGroupPaciente.add(rbtSi);
        rbtSi.setText("Sí");
        rbtSi.setActionCommand("N");
        rbtSi.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rbtSiActionPerformed(evt);
            }
        });

        rbtNo.setBackground(new java.awt.Color(204, 204, 255));
        rbtGroupPaciente.add(rbtNo);
        rbtNo.setText("No");
        rbtNo.setActionCommand("S");
        rbtNo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rbtNoActionPerformed(evt);
            }
        });

        jLabel1.setText("Odontologo:");

        txtTel.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtTelKeyPressed(evt);
            }
        });

        jLabel10.setText("Teléfono:");

        jLabel11.setText("Ape.Paterno");

        jLabel12.setText("Ape.Materno");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel3Layout.createSequentialGroup()
                        .addGap(35, 35, 35)
                        .addComponent(chkBoxAdelanto)
                        .addGap(18, 18, 18)
                        .addComponent(txtAdelanto, javax.swing.GroupLayout.DEFAULT_SIZE, 141, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel3Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel5)
                        .addGap(18, 18, 18)
                        .addComponent(comboMotivo, 0, 141, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel3Layout.createSequentialGroup()
                        .addGap(23, 23, 23)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel1)
                            .addComponent(jLabel2)
                            .addComponent(jLabel3)
                            .addComponent(jLabel4)
                            .addComponent(jLabel10)
                            .addComponent(jLabel6)
                            .addComponent(jLabel11)
                            .addComponent(jLabel12))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtMaterno, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(txtPaterno, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(txtCel, javax.swing.GroupLayout.DEFAULT_SIZE, 141, Short.MAX_VALUE)
                            .addComponent(txtNombre, javax.swing.GroupLayout.DEFAULT_SIZE, 141, Short.MAX_VALUE)
                            .addComponent(txtCodPaciente, javax.swing.GroupLayout.DEFAULT_SIZE, 141, Short.MAX_VALUE)
                            .addComponent(txtTel, javax.swing.GroupLayout.DEFAULT_SIZE, 141, Short.MAX_VALUE)
                            .addComponent(comboDr, 0, 141, Short.MAX_VALUE)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addComponent(rbtSi)
                                .addGap(18, 18, 18)
                                .addComponent(rbtNo)
                                .addGap(0, 0, Short.MAX_VALUE)))))
                .addGap(54, 54, 54))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(comboDr, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(rbtSi)
                    .addComponent(rbtNo))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(txtCodPaciente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtPaterno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel11))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 14, Short.MAX_VALUE)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtMaterno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel12))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel10, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(txtTel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(txtCel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(comboMotivo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtAdelanto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(chkBoxAdelanto))
                .addGap(24, 24, 24))
        );

        jPanel4.setBackground(new java.awt.Color(204, 204, 255));
        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 153)), "Seleccione fecha y hora de la cita", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tunga", 1, 14), new java.awt.Color(255, 255, 153))); // NOI18N

        jLabel7.setText("Hora:");

        jLabel8.setText("Mins");

        jLabel9.setText("Fecha:");

        dateCalendar.setCurrentView(new datechooser.view.appearance.AppearancesList("Grey",
            new datechooser.view.appearance.ViewAppearance("custom",
                new datechooser.view.appearance.swing.SwingCellAppearance(new java.awt.Font("Tahoma", java.awt.Font.PLAIN, 11),
                    new java.awt.Color(0, 0, 0),
                    new java.awt.Color(0, 0, 255),
                    false,
                    true,
                    new datechooser.view.appearance.swing.ButtonPainter()),
                new datechooser.view.appearance.swing.SwingCellAppearance(new java.awt.Font("Tahoma", java.awt.Font.PLAIN, 11),
                    new java.awt.Color(0, 0, 0),
                    new java.awt.Color(0, 0, 255),
                    true,
                    true,
                    new datechooser.view.appearance.swing.ButtonPainter()),
                new datechooser.view.appearance.swing.SwingCellAppearance(new java.awt.Font("Tahoma", java.awt.Font.PLAIN, 11),
                    new java.awt.Color(0, 0, 255),
                    new java.awt.Color(0, 0, 255),
                    false,
                    true,
                    new datechooser.view.appearance.swing.ButtonPainter()),
                new datechooser.view.appearance.swing.SwingCellAppearance(new java.awt.Font("Tahoma", java.awt.Font.PLAIN, 11),
                    new java.awt.Color(128, 128, 128),
                    new java.awt.Color(0, 0, 255),
                    false,
                    true,
                    new datechooser.view.appearance.swing.LabelPainter()),
                new datechooser.view.appearance.swing.SwingCellAppearance(new java.awt.Font("Tahoma", java.awt.Font.PLAIN, 11),
                    new java.awt.Color(0, 0, 0),
                    new java.awt.Color(0, 0, 255),
                    false,
                    true,
                    new datechooser.view.appearance.swing.LabelPainter()),
                new datechooser.view.appearance.swing.SwingCellAppearance(new java.awt.Font("Tahoma", java.awt.Font.PLAIN, 11),
                    new java.awt.Color(0, 0, 0),
                    new java.awt.Color(255, 0, 0),
                    false,
                    false,
                    new datechooser.view.appearance.swing.ButtonPainter()),
                (datechooser.view.BackRenderer)null,
                false,
                true)));
    dateCalendar.setFormat(2);
    dateCalendar.setLocale(new java.util.Locale("es", "PE", ""));
    dateCalendar.setBehavior(datechooser.model.multiple.MultyModelBehavior.SELECT_SINGLE);
    dateCalendar.addSelectionChangedListener(new datechooser.events.SelectionChangedListener() {
        public void onSelectionChange(datechooser.events.SelectionChangedEvent evt) {
            dateCalendarOnSelectionChange(evt);
        }
    });

    javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
    jPanel4.setLayout(jPanel4Layout);
    jPanel4Layout.setHorizontalGroup(
        jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel4Layout.createSequentialGroup()
            .addGap(18, 18, 18)
            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                .addComponent(jLabel9)
                .addComponent(jLabel7))
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(dateCalendar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(jPanel4Layout.createSequentialGroup()
                    .addComponent(comboHora, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(26, 26, 26)
                    .addComponent(jLabel8)
                    .addGap(18, 18, 18)
                    .addComponent(comboMins, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
            .addContainerGap(83, Short.MAX_VALUE))
    );
    jPanel4Layout.setVerticalGroup(
        jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel4Layout.createSequentialGroup()
            .addGap(76, 76, 76)
            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(dateCalendar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jLabel9))
            .addGap(27, 27, 27)
            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(comboHora, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jLabel7)
                .addComponent(jLabel8)
                .addComponent(comboMins, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addContainerGap(72, Short.MAX_VALUE))
    );

    btnRegistrarReserva.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pe/sonrisas/tools/imagenes/comun/calendar.png"))); // NOI18N
    btnRegistrarReserva.setText("Registrar reserva");
    btnRegistrarReserva.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnRegistrarReservaActionPerformed(evt);
        }
    });

    jScrollPane1.setBackground(new java.awt.Color(204, 204, 255));
    jScrollPane1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 204)), "Reservas del día", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tunga", 1, 14), new java.awt.Color(255, 255, 153))); // NOI18N

    tblReservasDelDia.setModel(new javax.swing.table.DefaultTableModel(
        new Object [][] {
            {null, null, null},
            {null, null, null},
            {null, null, null},
            {null, null, null},
            {null, null, null},
            {null, null, null},
            {null, null, null},
            {null, null, null},
            {null, null, null},
            {null, null, null},
            {null, null, null},
            {null, null, null},
            {null, null, null},
            {null, null, null},
            {null, null, null},
            {null, null, null},
            {null, null, null},
            {null, null, null},
            {null, null, null}
        },
        new String [] {
            "Hora", "Paciente", "Tratamiento"
        }
    ) {
        Class[] types = new Class [] {
            java.lang.String.class, java.lang.String.class, java.lang.String.class
        };
        boolean[] canEdit = new boolean [] {
            false, false, false
        };

        public Class getColumnClass(int columnIndex) {
            return types [columnIndex];
        }

        public boolean isCellEditable(int rowIndex, int columnIndex) {
            return canEdit [columnIndex];
        }
    });
    tblReservasDelDia.setAlignmentX(3.0F);
    jScrollPane1.setViewportView(tblReservasDelDia);
    tblReservasDelDia.getColumnModel().getColumn(0).setResizable(false);
    tblReservasDelDia.getColumnModel().getColumn(0).setPreferredWidth(8);

    javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
    jPanel2.setLayout(jPanel2Layout);
    jPanel2Layout.setHorizontalGroup(
        jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel2Layout.createSequentialGroup()
            .addGap(35, 35, 35)
            .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel2Layout.createSequentialGroup()
                    .addGap(33, 33, 33)
                    .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(3, 3, 3))
                .addGroup(jPanel2Layout.createSequentialGroup()
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnRegistrarReserva)
                    .addGap(71, 71, 71)))
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 388, Short.MAX_VALUE)
            .addContainerGap())
    );
    jPanel2Layout.setVerticalGroup(
        jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel2Layout.createSequentialGroup()
            .addContainerGap()
            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel2Layout.createSequentialGroup()
                    .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(51, 51, 51)
                    .addComponent(btnRegistrarReserva))
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 357, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGap(0, 56, Short.MAX_VALUE))
    );

    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(
        jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    );
    jPanel1Layout.setVerticalGroup(
        jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel1Layout.createSequentialGroup()
            .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addGap(0, 0, Short.MAX_VALUE))
    );

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    );
    layout.setVerticalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );

    pack();
    }// </editor-fold>//GEN-END:initComponents

    private void rbtSiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbtSiActionPerformed
        if (rbtSi.isSelected()) {
            limpiarCampos();
            txtCodPaciente.setEditable(false);
            txtNombre.requestFocus();
            habilitarCampos(true);
        }


    }//GEN-LAST:event_rbtSiActionPerformed

    private void chkBoxAdelantoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkBoxAdelantoActionPerformed
        if (chkBoxAdelanto.isSelected()) {
            txtAdelanto.setEditable(true);
            txtAdelanto.requestFocus();
            txtAdelanto.selectAll();
        } else {
            txtAdelanto.setText("Ingrese monto");
            txtAdelanto.setEditable(false);
        }
    }//GEN-LAST:event_chkBoxAdelantoActionPerformed

    private void rbtNoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbtNoActionPerformed
        if (rbtNo.isSelected()) {
            limpiarCampos();
            txtCodPaciente.setEditable(true);
            txtCodPaciente.requestFocus();
            habilitarCampos(false);

        }



    }//GEN-LAST:event_rbtNoActionPerformed

    private void txtCodPacienteKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtCodPacienteKeyPressed
        if (evt.getKeyCode() == evt.VK_ENTER) {
            if (validar.validarNro(txtCodPaciente.getText()) && !validar.esVacio(txtCodPaciente.getText())) {
                //txtCodPaciente.setText(validar.agregarCerosYNumeroAIncrementar(Integer.parseInt(txtCodPaciente.getText()), 0));
                buscarPaciente();

            } else {
                JOptionPane.showMessageDialog(this, "Ingrese un código");
                txtCodPaciente.requestFocus();
            }

        }
    }//GEN-LAST:event_txtCodPacienteKeyPressed

    private void btnRegistrarReservaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRegistrarReservaActionPerformed
        if (!validar.esVacio(txtNombre.getText()) && !validar.esVacio(txtTel.getText())) {


            /*
             * Obtenemos los datos a enviar como parámetros al control, de la
             * interfaz frmReservaCita
             */

            String hora = "", mins = "", fechaReserva = "";
            String codpaciente = "";
            double adelanto = 0;


            //Obtenemos hora y minutos elegidos en los combos para la reserva.

            hora = comboHora.getSelectedItem().toString();
            mins = comboMins.getSelectedItem().toString();

            //Armamos la fecha

            fechaReserva = validar.cambiarFormatoFechaParaBD(dateCalendar.getText()) + " " + hora + ":" + mins;


            if (rbtSi.isSelected()) {
                codpaciente = "no";
            } else {
                codpaciente = txtCodPaciente.getText();
            }


            if (chkBoxAdelanto.isSelected()) {
                adelanto = Double.parseDouble(txtAdelanto.getText());
            }

            int registroOk = 9;

            if (btnRegistrarReserva.getText().equals("Registrar reserva")) {
                ControlReserva control = new ControlReserva();

                
                int idMotivo = Integer.parseInt(motivos.get(comboMotivo.getSelectedIndex()).get(0).toString());
                int idOdontologo = Integer.parseInt(odontologos.get(comboDr.getSelectedIndex()).get(3).toString());
                
                //JOptionPane.showMessageDialog(this, idOdontologo);
                
                
                if (codpaciente.equals("no")){
                    JOptionPane.showMessageDialog(this, "No es paciente");
                    ControlPersona controlPersona = new ControlPersona();
                    controlPersona.agregarPersona(txtNombre.getText(), txtPaterno.getText(), txtMaterno.getText(), txtTel.getText(), txtCel.getText());
                    int idPersona = controlPersona.cargarCodigo(); 
                    System.out.println("Id persona "+idPersona);
                    registroOk = control.agregarReservaNoPaciente(idPersona, idMotivo, adelanto, fechaReserva, idOdontologo);
                          
                } else {
                
                registroOk = control.agregarReserva(codpaciente,idMotivo , adelanto, fechaReserva, idOdontologo);
            
                }
            
            } else {
                ControlReserva control = new ControlReserva();

                int resp = control.editarReserva(codreserva, fechaReserva, Integer.parseInt(comboMotivo.getSelectedItem().toString()), 2);

                if (resp == 2) {
                    JOptionPane.showMessageDialog(this, "La reserva ha sido modificada correctamente", "Modificar reserva", JOptionPane.INFORMATION_MESSAGE);
                }
                dispose();
            }



            switch (registroOk) {
                //Mensaje de error grave
                case 0:
                    JOptionPane.showMessageDialog(this, "No se pudo realizar la reserva. Contacte al administrador del sistema");
                    break;

                case 1:  // Mensaje de Reserva confirmada
                    JOptionPane.showMessageDialog(this, "Cita reservada correctamente", "Confirmación de reserva", JOptionPane.INFORMATION_MESSAGE);
                    // Mensaje preguntando si desea realizar reserva
                    int respuesta = JOptionPane.showConfirmDialog(this, "¿Desea realizar otra reserva de cita?", "Realizar otra reserva", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
                    if (respuesta == 0) {
                        limpiarCampos();
                        rbtNo.setSelected(true);
                        rbtNoActionPerformed(evt);
                    } else {
                        dispose();
                    }
                    break;

                //Mensaje de horario ya reservado.
                case 2:
                    JOptionPane.showMessageDialog(this, "Ya tiene una reserva en este horario, seleccione otro horario por favor", "Horario no disponible", JOptionPane.ERROR_MESSAGE);
                    comboHora.requestFocus();
                    break;
            }

            mostrarReservasDelDia();
        } else {
            JOptionPane.showMessageDialog(this, "Debe ingresar nombre y telefono", "Campos obligatorios", JOptionPane.ERROR_MESSAGE);
            txtNombre.requestFocus();
    }//GEN-LAST:event_btnRegistrarReservaActionPerformed
    }

    private void txtNombreKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtNombreKeyPressed
        if ((evt.getKeyCode() == evt.VK_ENTER) || (evt.getKeyCode() == evt.VK_TAB)) {
            if (validar.esVacio(txtNombre.getText())) {
                JOptionPane.showMessageDialog(this, "Debe ingresar un nombre", "Campo obligatorio", JOptionPane.ERROR_MESSAGE);
                txtNombre.requestFocus();
            } else if (validar.validarTexto(txtNombre.getText())) {
                txtTel.requestFocus();
            } else {
                JOptionPane.showMessageDialog(this, "El nombre no debe contener numeros/símbolos", "Error", JOptionPane.ERROR_MESSAGE);
                txtNombre.requestFocus();
                txtNombre.selectAll();
            }
        }

    }//GEN-LAST:event_txtNombreKeyPressed

    private void txtCelKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtCelKeyPressed
        if (evt.getKeyCode() == evt.VK_ENTER) {
            if (validar.validarNro(txtCel.getText()) && validar.validarLongitud(9, txtCel.getText())) {
                comboMotivo.requestFocus();
            } else {
                JOptionPane.showMessageDialog(this, "El celular sólo debe contener numeros y no debe superar los 9 dígitos", "Error", JOptionPane.ERROR_MESSAGE);
                txtCel.requestFocus();
                txtCel.selectAll();
            }
        }
    }//GEN-LAST:event_txtCelKeyPressed

    private void txtTelKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtTelKeyPressed
        if (evt.getKeyCode() == evt.VK_ENTER) {
            if (validar.validarNro(txtTel.getText())) {
                txtCel.requestFocus();
            } else {
                JOptionPane.showMessageDialog(this, "El teléfono sólo debe contener numeros", "Error", JOptionPane.ERROR_MESSAGE);
                txtTel.requestFocus();
                txtTel.selectAll();
            }
        }
    }//GEN-LAST:event_txtTelKeyPressed

    private void txtAdelantoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtAdelantoKeyPressed
        if (evt.getKeyCode() == evt.VK_ENTER) {
            if (!validar.validarAdelanto(txtAdelanto.getText())) {
                JOptionPane.showMessageDialog(this, "El adelanto no puede superar los S/.1000", "Error", JOptionPane.ERROR_MESSAGE);
                txtAdelanto.requestFocus();
                txtAdelanto.selectAll();
            }
        }
    }//GEN-LAST:event_txtAdelantoKeyPressed

    private void dateCalendarOnSelectionChange(datechooser.events.SelectionChangedEvent evt) {//GEN-FIRST:event_dateCalendarOnSelectionChange
     //   setearFecha();
        ControlHorarioOdontologo control = new ControlHorarioOdontologo();

        Vector<Vector> horario = control.dameHorarioDelDia(validar.cambiarFormatoFechaParaBD(""+dateCalendar.getSelection()), Integer.parseInt(odontologos.get(comboDr.getSelectedIndex()).elementAt(2).toString()));
        setearHorario(horario);
        borrarReservasDelDia();
        mostrarReservasDelDia();
    }//GEN-LAST:event_dateCalendarOnSelectionChange

    public void buscarPaciente() {
        try {

            co.Conectar();


            rs = co.Consultar("select pac.idPaciente,per.nombres,per.apellidoPaterno,per.apellidoMaterno,per.dni,per.nacionalidad,per.domicilio,per.email,per.telefono,per.celular,per.fechanac,per.genero,per.idUbigeo,pac.antecedentes,pac.ocupacion,pac.recomendadopor,pac.grupo,pac.fechaingreso from PERSONA per, PACIENTE pac where pac.idPaciente =" + txtCodPaciente.getText() + " and per.idPersona = pac.idpersona");

            if (rs.first()) {
                txtNombre.setText(rs.getString(2));
                txtPaterno.setText(rs.getString(3));
                txtMaterno.setText(rs.getString(4));
                txtTel.setText(rs.getString(9));
                txtCel.setText(rs.getString(10));
                comboMotivo.requestFocus();
            } else {
                JOptionPane.showMessageDialog(this, "No existe el paciente");
                limpiarCampos();
                int resp = JOptionPane.showConfirmDialog(this, "¿Desea buscar el paciente?", "Paciente no encontrado", JOptionPane.YES_OPTION, JOptionPane.QUESTION_MESSAGE);
                frmConsultarPaciente consu = new frmConsultarPaciente();
                if (resp == 0) {
                    dispose();
                    consu.setVisible(true);
                }
            }
            try {
                co.Desconectar();
            } catch (Exception ex) {
                Logger.getLogger(frmReservaCita.class.getName()).log(Level.SEVERE, null, ex);
            }
        } /**
         * @param args the command line arguments
         */
        catch (ClassNotFoundException ex) {
            Logger.getLogger(frmReservaCita.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(frmReservaCita.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    /*
     * BORRA LAS RESERVAS DE LA TABLA AL CAMBIAR DE FECHA
     */
    public void borrarReservasDelDia() {

        int n = tblReservasDelDia.getRowCount();

        for (int i = 0; i < n; i++) {
            tblReservasDelDia.setValueAt("", i, 0);
            tblReservasDelDia.setValueAt("", i, 1);
            tblReservasDelDia.setValueAt("", i, 2);
        }

    }

    /*
     * CONSULTA EN LA BD LAS RESERVAS DEL DIA DE LA FECHA SELECCIONADA PARA
     * SABER QUE HORARIOS ESTÁN DISPONIBLES
     */
    public void mostrarReservasDelDia() {

        //String query = "select * from RESERVACITA where fecha >" +"'"+ txtFecha.getText() +"'"+ " and fecha<" +"'"+ txtFecha.getText() + " 23:59:59"+"'"+ " and estado = 'Activa' order by fecha";
        ControlReserva control = new ControlReserva();
        ControlOdontologo odontologo = new ControlOdontologo();



        Vector<Vector> listadoReservas = control.listarReservasPorFechas(validar.cambiarFormatoFechaParaBD(dateCalendar.getSelection().toString()),  Integer.parseInt(odontologos.get(comboDr.getSelectedIndex()).elementAt(2).toString()));
             
        for (int i = 0; i < listadoReservas.size(); i++) {
            /*
             * Nombre paciente
             */ tblReservasDelDia.setValueAt(listadoReservas.get(i).elementAt(2) + " " + listadoReservas.get(i).elementAt(3), i, 1);
            //tblReservasDelDia.setValueAt(i, i, i)
         /*
             * Tratamiento
             */ tblReservasDelDia.setValueAt(listadoReservas.get(i).elementAt(4), i, 2);
            /*
             * Horario
             */ tblReservasDelDia.setValueAt(validar.obtenerHorarioDeCalendario("" + listadoReservas.get(i).elementAt(1)), i, 0);
        }        

    }
    /*
     * CARGA LOS TRATAMIENTOS REGISTRADOS EN LA TABLA BD, EN EL COMBOBOX DE
     * MOTIVO DE CONSULTA
     */
    public final void cargarTratamientos() {

        ControlTratamiento control = new ControlTratamiento();
        Vector<Vector> listadoTratamientos = control.listarTratamientos();

        //Agregamos al combo el nombre del Tratamiento
        for (int i = 0; i < listadoTratamientos.size(); i++) {
            comboMotivo.addItem(listadoTratamientos.get(i).elementAt(0));
        }

    }

    /*
     * MUESTRA UNA RESERVA EN PARTICULAR , BUSCÁNDOLA POR CÓDIGO DE RESERVA Y
     * SETEA LOS DATOS EN LAS CAJAS DE TEXTO
     */
    public void mostrarReserva(String cod) {


        String query = "select * from RESERVACITA where codreserva=" + cod;
        ControlReserva control = new ControlReserva();
        Vector<Vector> listado = control.listarReporte(query, 1);


        txtCodPaciente.setText("" + listado.get(0).elementAt(1));
        txtNombre.setText("" + listado.get(0).elementAt(3));
        txtTel.setText("" + listado.get(0).elementAt(4));
        txtCel.setText("" + listado.get(0).elementAt(5));
        comboMotivo.setSelectedItem("" + listado.get(0).elementAt(6));
        txtAdelanto.setText("" + listado.get(0).elementAt(7));
//        txtFecha.setText(validar.cambiarFormatoFecha(validar.obtenerDiaDeCalendario("" + listado.get(0).elementAt(8))));




        /*
         * Sólo deja habilitados los campos : Motivo de consulta y elegir una
         * fecha-hora . Además de cambiar el botón de 'Registrar' por
         * 'Modificar'
         */

        txtCodPaciente.setEnabled(false);
        rbtSi.setEnabled(false);
        rbtNo.setEnabled(false);
        habilitarCampos(false);
        btnRegistrarReserva.setText("Modificar reserva");
        comboMotivo.requestFocus();
        codreserva = cod;  // Almacena en la variable global reserva, el cod de la reserva para luego poder modificar.

    }//Fin_MostrarReserva

    /*
     * SETEA EL CÓDIGO QUE VIENE DESDE frmConsultarPaciente
     */
    public void setearCodigo(String cod) {
        txtCodPaciente.setText(cod);
    }
    /*
     * COLOCA EN EL TXTFECHA LA FECHA SELECCIONADA DEL CALENDARIO
     */
//    public final void setearFecha() {
//        txtFecha.setText(validar.formatearFechaDeCalendario("" + dateCalendar.getSelection()));
//    }

    public void setearHorario(Vector<Vector> horario) {


        if (horario.size() > 0) {

            int horaini = Integer.parseInt(horario.get(0).elementAt(0).toString().substring(0, 2));
            int horafin = Integer.parseInt(horario.get(0).elementAt(1).toString().substring(0, 2));
            comboHora.removeAllItems();
            comboMins.removeAllItems();
            for (int i = horaini; i <= horafin; i++) {
                comboHora.addItem(i);
            }
            comboHora.setEnabled(true);
            comboMins.setEnabled(true);

            comboMins.addItem("00");
            comboMins.addItem("10");
            comboMins.addItem("20");
            comboMins.addItem("30");
            comboMins.addItem("40");
            comboMins.addItem("50");


        } else {
            System.out.println("No trabaja ese dia");          
            comboHora.removeAllItems();
            comboMins.removeAllItems();
            comboHora.setEnabled(false);
            comboMins.setEnabled(false);
        }

    }

    public void cambiarFecha(int anho, int mes, int dia) {
        Calendar cambiarFecha = Calendar.getInstance();
        cambiarFecha.set(anho, mes, dia);
        dateCalendar.setSelectedDate(cambiarFecha);
    }


    /*
     * SETEA LA HORA EN LOS COMBOS HORA Y MINS DE LA HORA QUE VIENE DE LA
     * RESERVA A MODIFICAR , frmReporteReservas
     */
    public void cambiarHoraCombo(String h, String d) {
        comboHora.setSelectedItem(h);
        comboMins.setSelectedItem(d);

    }

    public void habilitarCampos(boolean habilitar) {

        txtNombre.setEditable(habilitar);
        txtTel.setEditable(habilitar);
        txtCel.setEditable(habilitar);

    }

    public void limpiarCampos() {
        txtCodPaciente.setText("");
        txtNombre.setText("");
        txtPaterno.setText("");
        txtMaterno.setText("");
        txtTel.setText("");
        txtCel.setText("");
    // ACTIVAR DESPUES ....    comboMotivoConsulta.setSelectedIndex(0);
        txtAdelanto.setText("");

    }

    public final void cargarOdontologos() {
        ControlOdontologo control = new ControlOdontologo();
        
        odontologos = control.listarTodos();


        for (int i = 0; i < odontologos.size(); i++) {
            comboDr.addItem(odontologos.get(i).elementAt(0) + " " + odontologos.get(i).elementAt(1));
        }

    }
    
     public final void cargarMotivos() {
        ControlMotivo control = new ControlMotivo();
        
        motivos = control.listarTodos();
        
         for (int i = 0; i < motivos.size(); i++) {
            comboMotivo.addItem(motivos.get(i).get(1));             
         }
        
        
        
    }
    
    

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {

                Visual.aspectoMac();
                frmReservaCita dialog = new frmReservaCita(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {

                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnRegistrarReserva;
    private javax.swing.JCheckBox chkBoxAdelanto;
    private javax.swing.JComboBox comboDr;
    private javax.swing.JComboBox comboHora;
    private javax.swing.JComboBox comboMins;
    private javax.swing.JComboBox comboMotivo;
    private datechooser.beans.DateChooserCombo dateCalendar;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.ButtonGroup rbtGroupPaciente;
    private javax.swing.JRadioButton rbtNo;
    private javax.swing.JRadioButton rbtSi;
    private javax.swing.JTable tblReservasDelDia;
    private javax.swing.JTextField txtAdelanto;
    private javax.swing.JTextField txtCel;
    private javax.swing.JTextField txtCodPaciente;
    private javax.swing.JTextField txtMaterno;
    private javax.swing.JTextField txtNombre;
    private javax.swing.JTextField txtPaterno;
    private javax.swing.JTextField txtTel;
    // End of variables declaration//GEN-END:variables

   
}
